package com.dexin.yang.manager.service.loginService.impl;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dexin.yang.base.service.impl.BaseServiceImpl;
import com.dexin.yang.entity.User;
import com.dexin.yang.manager.service.loginService.ILoginService;

@Service
public class LoginServiceImpl extends BaseServiceImpl<User, Long> implements ILoginService{

	@Override
	@Cacheable(value="userCache",key="'getUser'")
	public List<User> getUser() {
		// TODO Auto-generated method stub
		return getAll(User.class);
	}
	
	@CacheEvict(key="'getUser'",value="userCache")
	@Transactional(rollbackFor={RuntimeException.class,Exception.class},readOnly=false)
	@Override
	public void save(){
		User user = new User();
		user.setAdmin("1");
		user.setFlag("1");
		user.setName("ceshi1");
		user.setPassword("1231123");
		user.setUsername("ceshi1");
		
		User user1 = new User();
		user1.setAdmin("1");
		user1.setFlag("1");
		user1.setName("ceshi1");
		user1.setPassword("123");
		user1.setUsername("cesh2");
		save(user);
		save(user1);
	}

}
